
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource



def generate_launch_description():
    return LaunchDescription([
        Node(
            package='hobot_usb_cam',
            executable='hobot_usb_cam',
            name='hobot_usb_cam',
            parameters=[
                {"camera_calibration_file_path": "/opt/tros/lib/hobot_usb_cam/config/usb_camera_calibration.yaml"},
                {"frame_id": "default_usb_cam"},
                {"framerate": 30},
                {'image_width': 640},
                {'image_height': 480},
                {"io_method": "mmap"},
                {"pixel_format": "mjpeg"},
                {"video_device": "/dev/video8"},
                {"zero_copy": True}
                #{"zero_copy": False}
            ],
            arguments=['--ros-args', '--log-level', 'error']
        ),
        Node(
            package='hobot_codec',
            executable='hobot_codec_republish',
            output='screen',
            parameters=[
                    {"channel": 1},
                    {"in_mode": "shared_mem"},
                    {"in_format": "jpeg"},
                    {"out_mode": "ros"},
                    {"out_format": "bgr8"},
                    {"sub_topic": "/hbmem_image"},
                    {"pub_topic": "/image_raw1"}
            ],
            arguments=['--ros-args', '--log-level', 'error']
        ),           
        Node(
            package='opencv_pkg_python',
            executable='qrcode_detect'
        ),   
        Node(
            package='opencv_pkg_python',
            executable='image_processor'
        ),
        # IncludeLaunchDescription(
        #     PythonLaunchDescriptionSource('/root/dev_ws/src/origincar/origincar_base/launch/origincar_bringup.launch.py')
        # )
    ])